package cn.didi.feidi.javabackend.server.waterdeliver.utils;

import cn.didi.feidi.javabackend.mysql.jpa.waterDeliver.WaterDeliver;
import cn.didi.feidi.javabackend.server.waterdeliver.dto.LoginInfo;

import java.sql.Timestamp;

/**
 * Created by lindanpeng on 2017/7/16.
 */
public class EntityUtil {
    /**
     * 根据送水工信息生成id
     */
    public static String generateId( WaterDeliver waterDeliver){
        Timestamp timestamp=new Timestamp(System.currentTimeMillis());
        String id=waterDeliver.getPhoneNumber()+timestamp.getTime();
        return id;
    }
    /**
     * 根据信息生成token MD5(手机号+imei+时间戳)
     */
    public static String generateToken(LoginInfo loginInfo){
        Timestamp timestamp=new Timestamp(System.currentTimeMillis());
        String token=MD5Util.MD5(loginInfo.getPhoneNumber()+loginInfo.getImei()+timestamp.getTime());
        return token;
    }
}
